﻿//******************************************************************************************************
//  GeneratorGroupEntry.cs - Gbtc
//
//  Copyright © 2010, Grid Protection Alliance.  All Rights Reserved.
//
//  Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
//  the NOTICE file distributed with this work for additional information regarding copyright ownership.
//  The GPA licenses this file to you under the Eclipse Public License -v 1.0 (the "License"); you may
//  not use this file except in compliance with the License. You may obtain a copy of the License at:
//
//      http://www.opensource.org/licenses/eclipse-1.0.php
//
//  Unless agreed to in writing, the subject software distributed under the License is distributed on an
//  "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
//  License for the specific language governing permissions and limitations.
//
//  Code Modification History:
//  ----------------------------------------------------------------------------------------------------
//  07/09/2010 - Stephen C. Wills
//       Generated original version of source code.
//
//******************************************************************************************************

using System;
using TVA.Communication;

namespace TestBenchApi.Package
{
    /// <summary>
    /// Contains settings for a group of generators.
    /// </summary>
    public class GeneratorGroupEntry : Entry
    {

        #region [ Properties ]

        /// <summary>
        /// Gets or sets the number of generators in the group.
        /// </summary>
        public int NumberOfGenerators
        {
            get
            {
                return int.Parse(Settings["numberOfGenerators"]);
            }
            set
            {
                if (value <= 0)
                    throw new ArgumentException("value");

                Settings["numberOfGenerators"] = value.ToString();
            }
        }

        /// <summary>
        /// Gets or sets the start of the port range used by this group of generators.
        /// </summary>
        public int StartPort
        {
            get
            {
                return int.Parse(Settings["startPort"]);
            }
            set
            {
                if (value < 0)
                    throw new ArgumentOutOfRangeException("start port");

                if (value + NumberOfGenerators > 65536)
                    throw new ArgumentOutOfRangeException("end port");

                Settings["startPort"] = value.ToString();
            }
        }

        /// <summary>
        /// Gets or sets the input file used by this group of generators.
        /// </summary>
        public string InputFile
        {
            get
            {
                return Settings["inputFile"];
            }
            set
            {
                Settings["inputFile"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the configuration frame file used by this group of generators.
        /// </summary>
        public string ConfigurationFrameFile
        {
            get
            {
                return Settings["configFrameFile"];
            }
            set
            {
                Settings["configFrameFile"] = value;
            }
        }

        /// <summary>
        /// Gets or sets the frame rate of the input file used by the generator.
        /// </summary>
        public int FrameRate
        {
            get
            {
                return int.Parse(Settings["frameRate"]);
            }
            set
            {
                Settings["frameRate"] = value.ToString();
            }
        }

        /// <summary>
        /// Gets or sets the internet protocol used to send data to the concentrator.
        /// </summary>
        public TransportProtocol OutputProtocol
        {
            get
            {
                return (TransportProtocol)Enum.Parse(typeof(TransportProtocol), Settings["outputProtocol"], true);
            }
            set
            {
                Settings["outputProtocol"] = value.ToString();
            }
        }

        /// <summary>
        /// The access ID of the generators.
        /// </summary>
        public ushort AccessId
        {
            get
            {
                return ushort.Parse(Settings["accessId"]);
            }
            set
            {
                Settings["accessId"] = value.ToString();
            }
        }

        #endregion
        
    }
}
